package com.wjs.spring.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;

public class User implements BeanNameAware, BeanClassLoaderAware, BeanFactoryAware, InitializingBean, DisposableBean {
    private String name;
    public User() {
        System.out.println("第一步：实例化bean（在无参构造中完成）");
    }

    public void setName(String username) {
        this.name = username;
        System.out.println("第二步：bean属性赋值");
    }

    public void initBean(){
        System.out.println("第六步：初始化bean");
    }
    public void destroyBean(){
        System.out.println("第十步：销毁bean");
    }

    @Override
    public void setBeanClassLoader(ClassLoader classLoader) {
        System.out.println("第三步：类加载器："+classLoader);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("第三步：bean工厂："+beanFactory);
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("第三步：bean的名字："+name);
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("第九步：destroy方法的执行");
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("第五步：afterPropertiesSet方法的执行");
    }
}
